﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Windows8Accelerator.Core.Xaml.Helpers;

namespace Windows8Accelerator.Core.Xaml.Storage
{
    public abstract class StorageHelperBase
    {
        private static StorageHelperBase _Instance;
        public static StorageHelperBase Instance {
            get 
            {
                if (_Instance == null)
                    _Instance = AssemblyHelper.CreateInstanceOfAccelerator<StorageHelperBase>();
                return _Instance;
            }
        }

        public abstract Task<FileInfo[]> GetFilesAsync(string directory, StorageLocation storageLocation);

        public async Task<FileInfo[]> GetFilesAsync(StorageLocation storageLocation)
        {
            return await GetFilesAsync(null, storageLocation);
        }

        public abstract Task DeleteFilesAsync(string filePath, StorageLocation location);

        public abstract Task CreateFileAsync(string filePath, StorageLocation location);

        public abstract Task<Stream> OpenFileWriteAsync(string filePath, StorageLocation location, bool createIfNecessary = false);

        public abstract Task<Stream> OpenFileReadAsync(string filePath, StorageLocation location);
    }
}
